package com.basic.controller;

import com.area.entity.Brand;
import com.area.service.IBrandService;
import com.basic.entity.ProductInfoList;
import com.code.domain.AjaxResult;
import com.productinfo.entity.Productinfo;
import com.productinfo.entity.Vo.ProductInfoVo;
import com.productinfo.service.IProductinfoService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@Slf4j
@CrossOrigin
@ApiOperation(value = "基础数据",notes = "基础数据")
@RequestMapping(value = "/basic/productinfo")
public class ProductinfoBasicController {

    @Autowired
    private IProductinfoService productinfoService;

    @ApiOperation(value = "查询商品信息",notes = "查询商品信息")
    @PostMapping(value = "/queryProductInfos")
    public @ResponseBody AjaxResult queryProductInfos(){
        List<ProductInfoVo> productinfos = productinfoService.queryProductInfoAll();
        return AjaxResult.success("操作成功",productinfos);
    }

    @ApiOperation(value = "根据主键id查询",notes = "根据主键id查询")
    @GetMapping(value = "/queryProductInfoById/{productId}")
    public @ResponseBody AjaxResult queryProductInfoById(@PathVariable String productId){
        Productinfo productInfo = productinfoService.queryProductInfoById(productId);
        return AjaxResult.success("操作成功",productInfo);
    }

    @ApiOperation(value = "查询相关商品",notes = "查询相关商品")
    @GetMapping(value = "/queryRelevant/{productId}")
    public @ResponseBody AjaxResult queryRelevant(@PathVariable String productId){
        log.info("query===>"+productId);
        List<ProductInfoVo> productInfoVos = productinfoService.queryRelevantCommodity(productId);
        return AjaxResult.success("操作成功",productInfoVos);
    }


}
